package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.article.domain.StrategyThemeCopy;
import cn.wolfcode.luowowo.article.mapper.StrategyThemeCopyMapper;
import cn.wolfcode.luowowo.article.service.IStrategyThemeCopyService;
import cn.wolfcode.luowowo.query.StrategyThemeCopyQueryObject;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class StrategyThemeCopyServiceImpl implements IStrategyThemeCopyService {
    @Autowired
    private StrategyThemeCopyMapper strategyThemeCopyMapper;

    public PageInfo query(StrategyThemeCopyQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<StrategyThemeCopy> list = strategyThemeCopyMapper.selectForList(qo);
        return new PageInfo(list);
    }

    public void deleteById(Long id) {
        strategyThemeCopyMapper.deleteByPrimaryKey(id);
    }

    public void saveOrUpdate(StrategyThemeCopy strategyThemeCopy) {
        if(strategyThemeCopy.getId() == null){
            //新增操作
            strategyThemeCopyMapper.insert(strategyThemeCopy);
        }else{
            //更新操作
            strategyThemeCopyMapper.updateByPrimaryKey(strategyThemeCopy);
        }
    }


    /**
     * 查询所有的主题
     * @param qo
     * @return
     */
    public List<StrategyThemeCopy> selectAllThemesByType(StrategyThemeCopyQueryObject qo) {
        return strategyThemeCopyMapper.selectAllThemesByType(qo);
    }
}
